package thread;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

/**
 * @author : gscsd
 * @description: 1.
 * @date : 2025/9/27 14:18
 */
public class CallableImplCreateThread {
    public static void main(String[] args) throws Exception {
        MyCallable myCallable = new MyCallable();
        FutureTask<Integer> integerFutureTask = new FutureTask<>(myCallable);
        Thread thread = new Thread(integerFutureTask);
        thread.setName("callable_futuretask");
        thread.start();
        Integer i = integerFutureTask.get();
        System.out.println(i);
        System.out.println(Thread.currentThread().getName() + ">>>>" + "线程启动了");
    }
}

class MyCallable implements Callable<Integer> {
    @Override
    public Integer call() throws Exception {
        System.out.println(Thread.currentThread().getName() + ">>>>" + "线程启动了");
        return 1;
    }
}
